import * as API from '@/services'
import { createFetch } from '@/utils/request'
import { IResponseData } from '@/services'

/**
 * 账号 + 密码 登录
 */
export async function passwordLogin(params: API.PasswordLoginReq) {
  return createFetch<any, IResponseData<API.AuthInfo>>(
    '/api/v1/account-login',
    'POST',
  )({
    ...params,
    clientType: 'USER_WEB',
  })
}

/**
 * 手机/邮箱 + 验证码 登录
 */
export async function verificationCodeLogin(
  params: API.VerificationCodeLoginReq,
) {
  return createFetch<any, IResponseData<API.AuthInfo>>(
    '/api/v1/mobile-login',
    'POST',
  )({
    ...params,
    clientType: 'USER_WEB',
  })
}

/**
 * TOKEN 登录 (一般是三方登录才会用这个)
 */
export async function tokenLogin(token: string) {
  return createFetch<any, IResponseData<API.AuthInfo>>(
    '/api/v1/login-token-parse',
    'POST',
  )({
    token,
  })
}
